import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    goodlist:[]
  },
  getters: {
  },
  mutations: {
    add(state,obj){
      obj.flag=false
      console.log(obj.id);
      let index=state.goodlist.findIndex(item=>item.id==obj.id)
      console.log(index);
      if(index==-1){
        obj.num=1
        state.goodlist.push(obj)
      }else{
       state.goodlist[index].num+=1
      }
    }
  },
  actions: {
  },
  modules: {
  }
})
